This is a code that determines whether a number is positive, negative, or just 0
by Merrick '23
def positive_negative(x):
if x > 0:
return "pos"
elif x == 0:
return "0"
else:
return "neg"
| Function Call | Return Value | |||
|---|---|---|---|---|
| positive_negative(5) | → | |||
| positive_negative(-1) | → | |||
| positive_negative(0) | → | |||
| positive_negative(21) | → | |||
| positive_negative(-100) | → | |||
Experiment with this code on Gitpod.io